package cc.mrbird.febs.music.service.impl;

import cc.mrbird.febs.common.domain.QueryRequest;
import cc.mrbird.febs.common.utils.SortUtil;
import cc.mrbird.febs.music.dao.MusicMapper;
import cc.mrbird.febs.music.domain.MusicBean;
import cc.mrbird.febs.music.service.MusicService;
import cc.mrbird.febs.system.domain.User;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class MusicServiceImpl extends ServiceImpl<MusicMapper, MusicBean> implements MusicService {
    @Override
    public IPage<MusicBean> getData(MusicBean music, QueryRequest request) {
        Page<User> page = new Page<>();
        SortUtil.handlePageSort(request, page);
        if ("".equals(music.getDataType())) {
            return baseMapper.getData(page, music);
        } else {
            return baseMapper.getUserData(page, music);
        }
    }

}
